<?php
namespace App\Http\Controllers\ApiWx;

use App\DBs\FarmDB;
use App\DBs\VideoDB;
use Illuminate\Http\Request;

class VideoController extends BaseController
{
    //视频

    protected $db;

    public function __construct()
    {
        parent::__construct();
        $this->db = new VideoDB();
    }

    //产品列表
    public function getFarmIndex(Request $request)
    {
        $cate = $request->post('cate',0);
        $page = $request->post('page',1);
        $limit = $request->post('limit',10);
        $res = $this->db->getFarmIndex($cate,$page,$limit);
        if ($res['code']!=0) {
            return $this->toWxJson(-3);
        }
        return $this->toWxJson(0,$res['data'],$res['total']);
    }

    //视频列表
    public function getVideoIndex(Request $request)
    {
        $cate = $request->post('cate',0);
        $farm = $request->post('farm',0);
        $page = $request->post('page',1);
        $limit = $request->post('limit',10);
        $res = $this->db->getVideoIndex($cate,$farm,$page,$limit);
        if ($res['code']!=0) {
            return $this->toWxJson(-3);
        }
        return $this->toWxJson(0,$res['data'],$res['total']);
    }
}